﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace SimplexEngine
{
    public enum SceneObjectFilter
    { 
        LIGHT = 1,
        ENTITY = 2,
        CAMERA = 4,
        HUGE = 8,
        CUSTOM = 1024
    }

    public class SceneObject
    {
        public SceneNode Parent { get { return parent; } internal protected set { parent = value; } }
        protected SceneNode parent = null;

        public virtual int ObjectFilter { get { return 0; } }

        public SceneObject(String scene_object_name)
        {
            name = scene_object_name;
        }

        protected String name;
        public String Name { get { return name; } }

        protected BoundingBox aabb;
        public BoundingBox AABB { get { return aabb; } }

        public virtual Boolean Enable { get { return enable; } set { enable = value; } }
        protected Boolean enable = true;

        public virtual void Update(GameTime game_time, Int64 frame_number)
        {
            if (!Enable)
                return;

            // on update
            OnUpdate(game_time, frame_number);

        }
        protected virtual void OnUpdate(GameTime game_time, Int64 frame_number) { }

        public virtual Boolean Visible { get { return visible; } set { visible = value; } }
        protected Boolean visible = true;

        public virtual void Draw(GameTime game_time, Int64 frame_number)
        {
            if (!Visible)
                return;

            OnDraw(game_time, frame_number);
        }

        public virtual String TypeName { get { return "SceneObject"; } }

        public virtual Boolean Is(SceneObjectFilter filter)
        { 
            return ((int)filter & (int)ObjectFilter) != 0;
        }

        protected virtual void OnDraw(GameTime game_time, Int64 frame_number) { }
    }
}
